package com.innovationhero.mainUI.client.UX;

//import java.awt.List;
import java.util.ArrayList;
import java.util.SortedMap;
import java.util.TreeMap;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.logical.shared.AttachEvent;
import com.google.gwt.event.logical.shared.AttachEvent.Handler;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.shared.HandlerRegistration;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.innovationhero.mainUI.client.UX.IdeaUXEventHandler;
// JavaScript Object
import com.google.gwt.core.client.JavaScriptObject;


// import gwt-fx from http://gwt-fx.googlecode.com/svn/javadoc/0.5/org/adamtacy/client/ui/effects/impl/Fade.html
// 
//public class IdeaUX extends GwtEvent implements HandlerRegistration , EventHandler,
//MouseOverHandler, MouseOutHandler{
	public class IdeaUX {
	// final Grid grid = new Grid(2, 10);
	//grid.add(new HTML("<iframe width="480" height="390" src="http://www.youtube.com/embed/dRhn3mPlJtI" frameborder="0" allowfullscreen>
	// grid.add(new HTML("hello"));
	
//	grid.setCellSpacing(40);
//	rootPanel.add(grid, 0, 0);
//	grid.setSize("450px", "100px");
	 
		
	//	public static final GwtEvent.Type TYPE = new GwtEvent.Type();
	
	public IdeaUX(){
			 
// focusEffect() takes the returned Widget from ideaBar() and provides the effect
// OR implement MouseOverHandler or whatever the next undepreceated interface that adds
// will add onMouseOver 
		// EventListener ideaBarEL;
	//	http://stackoverflow.com/questions/879349/adding-a-mouseoverhandler-to-an-element 
		
		;
		
//		HandlerManager	eventBus = new HandlerManager(this);
//	    eventBus.addHandler(IdeaUX.TYPE, this);
		
		   HandlerManager eventBus = new HandlerManager(this);
		   SortedMap navPoints = new TreeMap();
		   
		   navPoints.put("1", "http://a0.twimg.com/profile_images/136103132/619239_wedding_flower_normal.jpg"); // Search
		   navPoints.put("2", "http://a0.twimg.com/profile_images/136103132/619239_wedding_flower_normal.jpg"); // Ideas
		   navPoints.put("3", "http://a0.twimg.com/profile_images/136103132/619239_wedding_flower_normal.jpg"); // Friends
		   navPoints.put("4", "http://a0.twimg.com/profile_images/136103132/619239_wedding_flower_normal.jpg"); // Profile 
		   navPoints.put("5", "http://a0.twimg.com/profile_images/136103132/619239_wedding_flower_normal.jpg"); // Settings

		   // instintiate  the Navigation bar and fire its events
		   
		    Navigation nav = new Navigation(navPoints ,eventBus);
		   
		   eventBus.fireEvent(new IdeaUXEvent());
	}
	
	/* the ideabar takes a custom datatype of "IdeaIllustrations" that contains  
	 * All the idea illustration URI, this datatype should be inherited from 
	 * a List Datatype or somthing similar to contain all the required URIs
	 * such as Audio, Video, Images, Txt, Custom formats
	 */
public Widget ideaBar()
{
	 final HorizontalPanel ideaBar = new HorizontalPanel();
	 ideaBar.add(ideaVideo("http://video.ted.com/talks/podcast/MattRidley_2010G.mp4"));
	 ideaBar.add(ideaVideo("http://video.ted.com/talks/podcast/TimBerners-Lee_2009.mp4"));
	 //	 ideaBar.add(ideaVideo("http://video.ted.com/talks/podcast/MattRidley_2010G.mp4"));
	 //ideaBar.insert(idea, 0);
	 
	 //	ideaBar.insert(clickMeButton, 1);
	 //	ideaBar.insert(clickMeButton, 2);
	   

	return ideaBar;
}


public Widget ideaVideo(String ideaVideoURI){
final HTML ideaVideoHTML5;
//String ideaVideoURI = ideaVideoURI;
	// "http://video.ted.com/talks/podcast/MattRidley_2010G.mp4";
ideaVideoHTML5 = new HTML();
ideaVideoHTML5.setHTML("<video width='400'" +
		"height='240'" +
		"controls='controls'>" +
//"<source src='movie.ogg' type='video/ogg' />" +
"<source src='" + ideaVideoURI + "' type='video/mp4' />" +
//"<source src='movie.webm' type='video/webm' />" +
"Your browser does not support the video tag." +
"</video>");

return ideaVideoHTML5; 
} 


public void focusEffect(Widget focusedIdea) {
	Handler handler = new Handler() {
		
		@Override
		public void onAttachOrDetach(AttachEvent event) {
			// TODO Auto-generated method stub
			
		}
	};;;
	focusedIdea.addAttachHandler(handler);
}


// UX Functions early defined in the UX IdeaUXEventHandler Interface

//public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
//	  return addDomHandler(handler, MouseOverEvent.getType());
//	}
//
//	public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
//	  return addDomHandler(handler, MouseOutEvent.getType());
//	}


	
//	
//@Override
//public void removeHandler() {
//	// TODO Auto-generated method stub
//	
//}
//
//@Override
//public void onMouseOver(MouseOverEvent event) {
//	// TODO Auto-generated method stub
//	
//}
//
//@Override
//public void onMouseOut(MouseOutEvent event) {
//	// TODO Auto-generated method stub
//	
//}
//
//@Override
//public Type getAssociatedType() {
//	// TODO Auto-generated method stub
//	return TYPE;
//	
//}
//
//protected void dispatch(IdeaUXEventHandler handler) {
//	// TODO Auto-generated method stub
//	handler.mouseOut(this.ideaBar());
//	handler.mouseOver(this.ideaBar());
//}

}